package com.system.healthproject.model.admin.controller;

import com.system.healthproject.bean.PagesBean;
import com.system.healthproject.bean.ResultTransaction;
import com.system.healthproject.common.ApiResult;
import com.system.healthproject.model.admin.service.TransactionInfoService;
import io.swagger.annotations.*;
import org.omg.IOP.TransactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 交易信息统计
 */

@Api(value = "后端-交易信息统计" ,tags = "后端-交易信息统计数据接口api")
@ApiResponses({
        @ApiResponse(code=400,message="请求参数不完整或者错误"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=415,message="请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code=500,message="后台服务错误")
})
@RequestMapping("/admin/transactionInfo")
@Controller
public class TransactionInfoController {

    @Autowired
    TransactionInfoService transactionService;

    /**
     *   医院交易信息统计
     * @param
     * @return
     */
    @RequestMapping(value = "/selectTransaction" ,method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ApiOperation(value = "查询交易信息统计",notes = "查询交易信息统计(后台已调试)",httpMethod = "post")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userName",value = "交易用户",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "transactionId",value = "流水账号（交易明细ID）",paramType = "query",dataType = "int",required = false),
            @ApiImplicitParam(name = "transactionStartTime",value = "开始时间（时间范围）",paramType = "query",dataType = "Date",required = false),
            @ApiImplicitParam(name = "transactionEndTime",value = "结束时间（时间范围查询）",paramType = "query",dataType = "Date",required = false),
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "limit",value = "每页显示数据条数",paramType = "query",dataType = "int",required = true),
    })
    @ResponseBody
    public ApiResult<PagesBean<ResultTransaction>> selectTransaction(
            @RequestParam(value = "currentPage",required = false) Integer currentPage,
            @RequestParam(value = "limit",required = false) Integer limit,
            String userName,
            String transactionId,
            String transactionStartTime,
            String transactionEndTime
    ){
        PagesBean<ResultTransaction> pagesBean=
                transactionService.selectTransactionList(
                        currentPage,limit,userName,transactionId,transactionStartTime,transactionEndTime);
        return new ApiResult(200,"成功",pagesBean);
    }


    /**
     *   导出医院交易信息统计记录
     * @param
     * @return
     */
    @RequestMapping(value = "/exportTransaction" ,method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ApiOperation(value = "导出交易信息统计",notes = "导出交易信息统计",httpMethod = "post",response = ApiResult.class)
    @ResponseBody
    public ApiResult exportTransaction(){
        return new ApiResult(200,"成功");
    }

}
